package com.lubase.core.runner;

import com.lubase.orm.extend.ExtendAppLoadCompleteService;
import com.lubase.orm.util.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Map;


@Order(2)
@Component
@Slf4j
public class RegisterApplicationRunner implements ApplicationRunner {
    @Override
    public void run(ApplicationArguments args) throws Exception {
        // 执行模块加载完成事件
        Map<String, ExtendAppLoadCompleteService> serviceMap = SpringUtil.getApplicationContext().getBeansOfType(ExtendAppLoadCompleteService.class);
        log.info(String.format("当前读取到loadCompleteServiceList数量为：%s", serviceMap.keySet().size()));
        for (String key : serviceMap.keySet()) {
            serviceMap.get(key).LoadCompleted(SpringUtil.getApplicationContext());
        }

        System.out.println("RegisterApplicationRunner 执行完毕");
    }
}
